package org.qiuqiu.action;

import javax.annotation.Resource;

import org.qiuqiu.service.PersonService;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionSupport;

@Controller
@Scope("prototype")
public class LoginAction extends ActionSupport {

    private static final long serialVersionUID = -1006252987556326592L;
//    @Resource默认是按照名称装配,找不到对应名字的则按照类型装配
    @Resource
    private PersonService ps;
    private String name;
    private String password;

    public PersonService getPs() {
	return ps;
    }

    public void setPs(PersonService ps) {
	this.ps = ps;
    }

    public String getName() {
	return name;
    }

    public void setName(String name) {
	this.name = name;
    }

    public String getPassword() {
	return password;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    @Override
    public String execute() throws Exception {
	System.out.println("收到信息-----------");
	if (ps.login(name, password) != null) {
	    return SUCCESS;
	} else {
	    return ERROR;
	}
    }
}
